<template>
	<view class="page">
		<template>
			<view v-if="upRoutes.routesName">
				<view class="tableTitle" >
					{{upRoutes.routesName ? upRoutes.routesName:'--'}}
				</view>
				<view class="miniTable">
					<view class="row tableHead">
						<view class="item">
							{{language.busTrack.label1}}
						</view>
						<view class="item">
							{{language.busTrack.label2}}
						</view>
						<view class="item">
							{{language.busTrack.label3}}
						</view>
					</view>
					<view class="row">
						<view class="item">
							{{upRoutes.upSiteName ? upRoutes.upSiteName:''}}
						</view>
						<view class="item" :style="upRoutes.upSiteTime?'color: #5ac725;':''">
							{{upRoutes.upSiteTime ? '已上车':'未上车'}}
						</view>
						<view class="item">
							{{upRoutes.upSiteTime ? upRoutes.upSiteTime:'--'}}
						</view>
					</view>
					<view class="row">
						<view class="item">
							{{upRoutes.downSiteName ? upRoutes.downSiteName : '--'}}
						</view>
						<view class="item" :style="upRoutes.downSiteTime?'color: #5ac725;':''">
							{{upRoutes.downSiteTime ? '已下车':'未下车'}}
						</view>
						<view class="item">
							{{upRoutes.downSiteTime ? upRoutes.downSiteTime:'--'}}
						</view>
					</view>
				</view>
				<view class="lineBox">
					<u-steps :current="siteUpCurrent" direction="column">
							<u-steps-item v-for="(item,index) in upRoutes.siteList" :title="item.siteName" :desc="item.siteTime ? item.siteTime :'-'">
							</u-steps-item>
					</u-steps>
				</view>
			</view>
			<view style="margin-top:40rpx;" v-if="downRoutes.routesName">
					<view class="tableTitle">
						{{downRoutes.routesName ? downRoutes.routesName:'--'}}
					</view>
					<view class="miniTable">
						<view class="row tableHead">
							<view class="item">
								{{language.busTrack.label1}}
							</view>
							<view class="item">
								{{language.busTrack.label2}}
							</view>
							<view class="item">
								{{language.busTrack.label3}}
							</view>
						</view>
						<view class="row">
							<view class="item">
								{{downRoutes.upSiteName ? downRoutes.upSiteName:''}}
							</view>
							<view class="item" :style="downRoutes.upSiteTime?'color: #5ac725;':''">
								{{downRoutes.upSiteTime ? '已上车':'未上车'}}
							</view>
							<view class="item">
								{{downRoutes.upSiteTime ? downRoutes.upSiteTime:'--'}}
							</view>
						</view>
						<view class="row">
							<view class="item">
								{{downRoutes.downSiteName ? downRoutes.downSiteName : '--'}}
							</view>
							<view class="item" :style="downRoutes.downSiteTime?'color: #5ac725;':''">
								{{downRoutes.downSiteTime ? '已下车':'未下车'}}
							</view>
							<view class="item">
								{{downRoutes.downSiteTime ? downRoutes.downSiteTime:'--'}}
							</view>
						</view>
					</view>
					<view class="lineBox">
						<u-steps :current="siteDownCurrent" direction="column">
								<u-steps-item v-for="(item,index) in downRoutes.siteList" :key="index" :title="item.siteName" :desc="item.siteTime ? item.siteTime :'-'">
								</u-steps-item>
						</u-steps>
					</view>
				</view>
			
		</template>
		
			<u-empty mode="list" v-if="!downRoutes.routesName && !upRoutes.routesName" :text="language.busTrack.tips">
			</u-empty>
		
	</view>
</template>

<script>
	import {parentCheckSiteListApi} from '@/common/api/commonApi/safeApi.js'
	export default {
		data() {
			return {
				list:[],
				params:{
					personId: uni.getStorageSync('selectInfoAccount').id,
					studentId : '',
				},
				startDate: Number(new Date()),
				endDate: Number(new Date()),
				startDateShow : false,
				endDateShow : false,
				total : 0,
				isTeacher: 1,
				siteUpCurrent:0,
				upRoutes:{},
				siteDownCurrent: 0,
				downRoutes:{},
			}
		},
		computed:{
		},
		components:{
		},
		methods: {
			handleSubmit(){
				if(!this.params.startDate) return this.setMessage('请选择有效开始时间')
				if(!this.params.endDate) return this.setMessage('请选择有效结束时间')
				acTemporaryGeneralAddApi(this.params).then(res=>{
						this.setMessage('操作成功')
				})
			},
			handleDetail(item){
				this.goPage('/pages/componentsC/safe/accessRecordDetail',{id:1})
			},
			scrolltolower(){
				if(this.total == this.list.length){
					return this.setMessage('没有更多了')
				}
				this.params.currPage ++
				this.getDetail()
			},
			startDateConfirm(e){
				let date = this.dateformat(e.value)
				this.params.startDate = date
				console.log(this.params.startDate);
				this.startDateShow = false
			},
			endDateConfirm(e){
				let date = this.dateformat(e.value)
				this.params.endDate = date
				this.endDateShow = false
			},
			getDetail(){
				let params = this.params
				parentCheckSiteListApi(params).then(res=>{
					if(res.result.upRoutes){
						this.upRoutes = res.result.upRoutes[0]
						this.upRoutes.siteList.forEach((item,index)=>{
							if(item.toSiteState==1) this.siteUpCurrent = index
						})
					}
					if(res.result.downRoutes){
						this.downRoutes = res.result.downRoutes[0]
						this.downRoutes.siteList.forEach((item,index)=>{
							if(item.toSiteState==1) this.siteDownCurrent = index
						})
					}
				})
			},
			
		},
		onLoad() {
			this.setPageTitle(this.language.busTrack.title)
			this.getDetail()
		},
		onShow() {
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #f2f2f2;
	padding-bottom: 100rpx;
	// height: 100vh;
	.searchBox{
		display: flex;
		align-items: center;
		background-color: #fff;
		padding: 0 20rpx;
		border-bottom: 1px solid #f1f1f1;
		margin: 20rpx;
		border-radius: 8rpx;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		.inputBox{
			flex: 1;
			padding-right: 30rpx;
			.inputRow{
				height: 80rpx;
				display: flex;
				align-items: center;
				font-size: 32rpx;
				padding-left: 20rpx;
				.label{
					color: #191919;
					margin-right: 30rpx;
				}
			}
			.input{
				
			}
			.emty{
				color: #c0c4cc;
			}
			.val{
				
			}
		}
		.btnBox{
			display: flex;
			flex-direction: column;
			padding: 10rpx 0;
			.reset{
				margin-top: 20rpx;
				border: 1px solid #f1f1f1;
				background: #fff !important;
				color: #353535 !important;
			}
			.btn{
				padding: 0 30rpx;
				// width: 110rpx;
				height: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background: #1890ff;
				border-radius: 8rpx;
				color: #fff;
			}
		}
	}
	
	.tableTitle{
		margin: 20rpx;
		height: 100%;
		color: #1890ff;
	}
	.lineBox{
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: wrap;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		background: #fff;
		margin: 20rpx;
		padding: 30rpx;
		height: 100%;
		border-radius: 8rpx;
	}
	.miniTable{
		display: flex;
		flex-wrap: wrap;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		background: #fff;
		margin: 20rpx;
		height: 100%;
		border-radius: 8rpx;
		overflow: hidden;
		.tableHead{
			background-color: #1890ff;
			color: #fff;
		}
		.row{
			width: 100%;
			height: 80rpx;
			display: flex;
			.item{
				display: flex;
				align-items: center;
				justify-content: center;
				flex: 1;
			}
		}
	}
	
	.contentBox{
		display: flex;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		background: #fff;
		margin: 20rpx;
		height: 100%;
		padding: 20rpx;
		border-radius: 8rpx;
		// width: 95%;
		.itemBox{
			width: 50%;
			padding: 10rpx;
		}
		.left{
			border-right: 1px solid #f1f1f1;
		}
		.right{
			margin-top: 80rpx;
		}
		.leftRow{
			display: flex;
			align-items: center;
			height: 160rpx;
		}
		.rightRow{
			display: flex;
			justify-content: flex-end;
			align-items: center;
			height: 160rpx;
		}
		.text{
			flex:1;
			margin: 10rpx;
		}
	}
}
</style>
